<?php
global $_W;
$sql = "
/*!40101 SET NAMES utf8 */;
CREATE TABLE `ims_homework_user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(10) unsigned NOT NULL COMMENT '公众号ID',
  `openid` varchar(50) NOT NULL COMMENT 'openid',
  `role` varchar(10) NOT NULL COMMENT '管理员，老师，学生',
  `name` varchar(10) NOT NULL COMMENT '用户姓名',
  PRIMARY KEY (`id`),
  UNIQUE KEY (`openid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='用户表';

CREATE TABLE `ims_homework_cabinet_admin` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(10) unsigned NOT NULL COMMENT '公众号ID',
  `userid` varchar(255) NOT NULL COMMENT '用户ID：多个逗号隔开',
  `device_info_id` int(10) unsigned NOT NULL COMMENT '设备信息ID',
  `device_name` varchar(20) NOT NULL COMMENT '设备名称',
  `door_num` int(3) unsigned NOT NULL COMMENT '柜门总数量',
  `remark` varchar(20) NOT NULL COMMENT '备注信息',
  `time` int(10) unsigned NOT NULL COMMENT '二维码更新时间',
  `random` char(10) NOT NULL COMMENT '随机码',
  PRIMARY KEY (`id`),
  UNIQUE KEY (`device_info_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='柜子与管理员表';

CREATE TABLE `ims_homework_door_teacher` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(10) unsigned NOT NULL COMMENT '公众号ID',
  `userid` varchar(10) NOT NULL COMMENT '用户ID',
  `device_info_id` int(10) unsigned NOT NULL COMMENT '设备信息ID',
  `door` int(3) unsigned NOT NULL COMMENT '柜门号',
  `remark` varchar(20) NOT NULL COMMENT '备注信息',
  `time` int(10) unsigned NOT NULL COMMENT '二维码更新时间',
  `random` char(10) NOT NULL COMMENT '随机码',
  PRIMARY KEY (`id`),
  UNIQUE KEY (`device_info_id`,`door`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='柜门与老师表';

CREATE TABLE `ims_homework_door_student` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(10) unsigned NOT NULL COMMENT '公众号ID',
  `userid` varchar(255) NOT NULL COMMENT '用户ID：多个逗号隔开',
  `device_info_id` int(10) unsigned NOT NULL COMMENT '设备信息ID',
  `door` int(3) unsigned NOT NULL COMMENT '柜门号',
  `remark` varchar(20) NOT NULL COMMENT '备注信息',
  `time` int(10) unsigned NOT NULL COMMENT '二维码更新时间',
  `random` char(10) NOT NULL COMMENT '随机码',
  PRIMARY KEY (`id`),
  UNIQUE KEY (`device_info_id`,`door`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='柜门与学生表';

";
pdo_query($sql);
?>